﻿using MiniExcelLibs.Attributes;
using SqlSugar;
using System;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;

namespace Qy.Scenario;
[SugarTable(DbTableName.QyAdminUser)]
public class User
{
    [SugarColumn(IsPrimaryKey = true)]
    public int Id { get; set; }
    public int DeptId { get; set; }
    public int PostId { get; set; }
    public int GroupId { get; set; }
    public string UserName { get; set; }
    public string PassWord { get; set; }
    public string NickName { get; set; }
    public DateTime LoginTime { get; set; }
    public string LoginIp { get; set; }
    public bool Status { get; set; } = true;
    public int Sex { get; set; }
    public string Avatar { get; set; }
    public string Phone { get; set; }
}

public class EditUser
{
    public int Id { get; set; }
    [Required(ErrorMessage = "请输入{0}")]
    [Display(Name = "所属部门")]
    public int DeptId { get; set; }
    [Required(ErrorMessage = "请输入{0}")]
    [Display(Name = "岗位")]
    public int PostId { get; set; }
    [Required(ErrorMessage = "请输入{0}")]
    [Display(Name = "角色")]
    public int GroupId { get; set; }
    [Display(Name = "登录名")]
    [Required(ErrorMessage = "请输入{0}")]
    [RegularExpression(RegxPatterns.EnOrNumber, ErrorMessage = "{0}英文下划线或数字")]
    [StringLength(16, MinimumLength = 2, ErrorMessage = "{0}至少{2}位,并且不能超过{1}位")]
    public string UserName { get; set; }
    [Display(Name = "密码")]
    public string PassWord { get; set; }
    [Display(Name = "旧密码")]

    public string OldPassword { get; set; }
    [Display(Name = "姓名")]
    [RegularExpression(RegxPatterns.Chs, ErrorMessage = "{0}必须为中文")]
    [StringLength(16, MinimumLength = 2, ErrorMessage = "{0}至少{2}位,并且不能超过{1}位")]
    [Required(ErrorMessage = "请输入{0}")]
    public string NickName { get; set; }
    [Display(Name = "用户状态")]
    [Required(ErrorMessage = "请选择用户状态")]
    public bool Status { get; set; } = true;
    public DateTime LoginTime { get; set; }
    public string LoginIp { get; set; }
    [Display(Name = "性别")]
    public int Sex { get; set; }
    [Display(Name = "头像")]
    public string Avatar { get; set; }
    [Display(Name = "联系电话")]
    public string Phone { get; set; }
}

public class EditUserStatus
{
    public int Id { get; set; }
    public bool Status { get; set; }
}

public class ViewUser
{
    public int Id { get; set; }
    public int DeptId { get; set; }
    public int PostId { get; set; }

    [ExcelColumnName("部门")]
    public string DeptName { get; set; }

    [ExcelColumnName("岗位")]
    public string PostName { get; set; }
    [ExcelColumnName("岗位标识码")]
    public string PostCode { get; set; }
    [ExcelColumnName("角色ID")]
    public int GroupId { get; set; }

    [ExcelColumnName("角色")]
    public string GroupName { get; set; }

    [ExcelColumnName("用户名")]
    public string UserName { get; set; }

    [ExcelColumnName("昵称")]
    public string NickName { get; set; }
    [DisplayName("用户状态")]
    public bool Status { get; set; } = true;
    [ExcelColumn(Name = "登录时间", Format = "yyyy-MM-dd HH:mm:ss")]
    public DateTime LoginTime { get; set; }
    public string LoginIp { get; set; }
    [ExcelColumnName("性别")]
    public int Sex { get; set; }
    [ExcelColumnName("头像")]
    public string Avatar { get; set; }
    [ExcelColumnName("联系电话")]
    public string Phone { get; set; }

}


public class UserIdAndName
{
    public int Id { get; set; }
    public string UserName { get; set; }
    public string NickName { get; set; }
    public string DeptName { get; set; }
    public bool Status { get; set; }

}


/// <summary>
/// 查询模型
/// </summary>
public class UserQuery:PagerInfo
{
    public int DeptId { get; set; } = 0;
    public bool? Status { get; set; }
    public string NickName { get; set; }
    public string UserName { get; set; }
    public bool ExportExcel { get; set; } = false;
}
